let print = console.log;
let readline = function () {
  return 'HTHHHHTHTTTT';
};

let str = readline();

let findNotInterestNum1 = /^(HH|TT)/g;
let findNotInterestNum2 = /(HHH|TTT)/g;
let findNotInterestNum3 = /(HH|TT)$/g;

String.prototype.icyMatch = function (reg) {

  let count = 0;
  let str = this;

  function reMatch() {
    let lastResult = reg.exec(str);

    console.log(lastResult, count);

    if (lastResult) {
      
      reg.lastIndex = lastResult.index + 1;
      count++;

      reMatch();
    }
  }

  reMatch();

  return count;
}

num = str.icyMatch(findNotInterestNum1) + str.icyMatch(findNotInterestNum2) + str.icyMatch(findNotInterestNum3);

print(str.length - num);